package com.wjerp.tplus.server.common.constant;

import java.text.MessageFormat;

/**
 * 账户变更类型
 * @author lishuailei
 */
public enum AccountChangeType {
    ADD_CHECK_NUM("add_check_num","新增校验次数"),
    SUBTRACT_CHECK_NUM("subtract_check_num","扣除校验次数"),
    ADD_OCR_NUM("add_ocr_num","新增OCR次数"),
    SUBTRACT_OCR_NUM("subtract_ocr_num","扣除OCR次数"),
    RECHARGE("recharge","充值"),
    ;

    private String code;
    private String message;

    AccountChangeType(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * Resolve.
     *
     * @param code the code
     * @return the error detail
     */
    public static AccountChangeType resolve(String code) {
        for (AccountChangeType item : values()) {
            if (item.getCode().equalsIgnoreCase(code)) {
                return item;
            }
        }
        return null;
    }

    /**
     * With parameters.
     *
     * @param params the parameters
     * @return the string
     */
    public String withParams(Object... params) {
        return MessageFormat.format(this.message, params);
    }

}
